package com.java.tutorials.spring.springInAction4th.chapter12.neo4j.config;

import org.neo4j.ogm.session.SessionFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.neo4j.config.Neo4jConfiguration;
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
import org.springframework.data.neo4j.server.Neo4jServer;
import org.springframework.data.neo4j.server.RemoteServer;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@Configuration
@ComponentScan({"org.springframework.data.neo4j.transactions"})
@EnableTransactionManagement
@EnableNeo4jRepositories(basePackages = "com.java.tutorials.spring.springInAction4th.chapter12.neo4j.db")
public class Neo4jConfig extends Neo4jConfiguration  {

	public Neo4jConfig() {
//		setBasePackage("orders");
	}

	@Bean
	public Neo4jServer neo4jServer() {
		return new RemoteServer("http://localhost:7474");
	}

	@Bean
	@Override
	public SessionFactory getSessionFactory() {
		return new SessionFactory("com.java.tutorials.spring.springInAction4th.chapter12.neo4j");
	}

//	@Bean(destroyMethod="shutdown")
//	public GraphDatabaseService graphDatabaseService() {
//		return new GraphDatabaseFactory()
//				.newEmbeddedDatabase("/tmp/graphdb");
//	}
}